package com.ruoyi.yipaiju.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yipaiju.domain.Aerich;
import com.ruoyi.yipaiju.service.IAerichService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * fo_aerichController
 * 
 * @author liuwp
 * @date 2023-03-01
 */
@RestController
@RequestMapping("/yipaiju/aerich")
public class AerichController extends BaseController
{
    @Autowired
    private IAerichService aerichService;

    /**
     * 查询fo_aerich列表
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:aerich:list')")
    @GetMapping("/list")
    public TableDataInfo list(Aerich aerich)
    {
        startPage();
        List<Aerich> list = aerichService.selectAerichList(aerich);
        return getDataTable(list);
    }

    /**
     * 导出fo_aerich列表
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:aerich:export')")
    @Log(title = "fo_aerich", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Aerich aerich)
    {
        List<Aerich> list = aerichService.selectAerichList(aerich);
        ExcelUtil<Aerich> util = new ExcelUtil<Aerich>(Aerich.class);
        util.exportExcel(response, list, "fo_aerich数据");
    }

    /**
     * 获取fo_aerich详细信息
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:aerich:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aerichService.selectAerichById(id));
    }

    /**
     * 新增fo_aerich
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:aerich:add')")
    @Log(title = "fo_aerich", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Aerich aerich)
    {
        return toAjax(aerichService.insertAerich(aerich));
    }

    /**
     * 修改fo_aerich
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:aerich:edit')")
    @Log(title = "fo_aerich", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Aerich aerich)
    {
        return toAjax(aerichService.updateAerich(aerich));
    }

    /**
     * 删除fo_aerich
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:aerich:remove')")
    @Log(title = "fo_aerich", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aerichService.deleteAerichByIds(ids));
    }
}
